import React, { useState, useEffect, useRef } from "react";
import { Modal } from "antd";
import OperaCard from "./components/OperaCard";
import ClassifyCard from "./components/ClassifyCard";
import OrderInfoCard from "./components/OrderInfoCard";
import ClassifyDataCard from "./components/ClassifyDataCard";
import CommonLoading from "@/components/CommonLoading";
import Style from "./index.module.less";


import { checkComponentsIsOpen } from "@/utils/print.jsx";

const InvoiceDelivery = () => {
	const [loading, setLoading] = useState(false);
	const [isModal, setModal] = useState(false);
	// 扫描返回的数据
	const [data, setData] = useState({});

	useEffect(() => {
		console.log("数据发生变化了", data);
	}, [data]);
	const RefOperaCard = useRef();

	//公共提示modalconfirm
	const commonModalConfirm = (content, callball) => {
		setModal(true);
		Modal.info({
			centered: true,
			title: "提示信息",
			content,
			onOk: () => {
				setModal(false);
				callball && callball();
			}
		});
	};

	useEffect(() => {
		// setLoading(true);
		checkComponentsIsOpen(
			undefined,
			res => {
				// if (res.errArr) {
				// 	const content = (
				// 		<div>
				// 			检测到您未开启<span style={{ fontWeight: "bold", wordBreak: "break-all" }}>【{res.errArr.join("，")}】</span>
				// 			打印组件，为不影响相关订单打印功能，请先及时开启（打印组件可去ERP首页进行下载）
				// 		</div>
				// 	);
				// 	commonModalConfirm(content, () => {
				// 		RefOperaCard.current.resetScanTask();
				// 	});
				// 	setLoading(false);
				// }
			},
			false
		);
	}, []);

	return (
		<>
			<div className={Style.container} style={{ overflow: "auto" }}>
				<div className={Style.leftMain}>
					<OperaCard ref={RefOperaCard} data={data} setData={setData} />
					<ClassifyCard data={data} />
				</div>
				<div className={Style.rightMain}>
					<OrderInfoCard data={data} />
					<ClassifyDataCard data={data} />
				</div>
			</div>
			<CommonLoading loading={loading} />
		</>
	);
};

export default React.memo(InvoiceDelivery, () => {
	return true;
});
